package com.shundr.shipper.common.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shundr.shipper.R;
import com.shundr.shipper.common.model.AttributeInfo;

/**
 * 
 * AttributeAdapter 基本数据适配器
 * 
 * @author larry 2015-4-13 下午4:26:47 
 * @version 1.0.0
 *
 */
public class AttributeAdapter extends BaseAdapter{
	public List<AttributeInfo> mList;
	private Context mContext;

	@Override
	public int getCount() {
		return mList.size();
	}

	@Override
	public Object getItem(int index) {
		return mList.get(index);
	}

	@Override
	public long getItemId(int id) {
		return id;
	}

	public AttributeAdapter(List<AttributeInfo> list, Context mContext) {
		super();
		this.mList = list;
		this.mContext = mContext;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup viewGroup) {
		ViewHold viewHold = null;
		if(convertView == null){
			convertView = LayoutInflater.from(mContext).inflate(R.layout.item_order_status,null);
			viewHold = new ViewHold();
			viewHold.tvValue = (TextView) convertView.findViewById(R.id.tv_value);
			convertView.setTag(viewHold);
		}else{
			viewHold = (ViewHold) convertView.getTag();
		}
		try {
			AttributeInfo info = mList.get(position);
			viewHold.tvValue.setText(info.getName());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return convertView;
	}

	static class ViewHold{
		TextView tvValue;
	}
}
